package zuoye;

import util.Util;

import javax.swing.*;
import java.awt.*;

public class Mainjframe extends JFrame {
    private CardLayout cardLayout = new CardLayout();
    private Loginjpanel loginjpanel = new Loginjpanel(this);
    private Menujpanel menujpanel = new Menujpanel(this);
    private Savejpanel savejpanel = new Savejpanel(this);
    private Getjpanel getjpanel = new Getjpanel(this);
    private Findjpanel findjpanel = new Findjpanel(this);
    private Image bgimage = Util.getImage("/images/background.jpg");

    public Mainjframe() {
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgimage, 0, 0, 1200, 800, this);
            }
        });
        this.setLayout(cardLayout);
        this.add("login", loginjpanel);
        this.add("menu", menujpanel);
        this.add("Save", savejpanel);
        this.add("Get", getjpanel);
        this.add("Find", findjpanel);
        this.setSize(1200, 800);
        this.setVisible(true);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
    }

    public void switchPanel(String name) {
        cardLayout.show(this.getContentPane(), name);
    }

    public static void main(String[] args) {
        new Mainjframe();
    }
}
